@echo off


set armdir=c:\arm
set sdkdir=..\sdk
set lib_o=..\Lib.o
set p_name=MotoCMD
set options=-DAPP_FTR_ERROR_SOUND -DAPP_FTR_FAST -DAPP_FTR_REMOVE_DIR_BY_FW

set opt_l7e=-DFTR_L7E

set src_input=motocmd.c icons.c lang.c util.c input.c edit.c output.c arch_br.c

set tmp_o=motocmd.o icons.o lang.o util.o reg.o input.o edit.o output.o arch_br.o
set ext_o=..\dbg\dbg.o ..\classes\class_ini.o ..\libs\libc.o ..\classes\ccfile.o

set files_to_pack=readme.txt motocmd.ini %p_name%.elf


set output=%p_name%.elf
%armdir%\tcpp -I"%sdkdir%" -c -bigend -O2 -apcs /interwork %options% reg.cpp
%armdir%\tcc -I"%sdkdir%" -c -bigend -O2 -apcs /interwork %options% %src_input%
%armdir%\armlink -reloc -first Lib.o(Lib) -o %output% %tmp_o% %ext_o% %lib_o%
del %tmp_o%
if exist %output% (
	echo ACK: File `%output%` created
) else (
	echo ERR: File `%output%` not created
)
echo ---------------------------------------
7z a -tzip -r -mx9 %p_name%_no_l7eFS.zip %files_to_pack% > _7z.log
echo ***************************************
echo ---------------------------------------

set output=%p_name%.elf
%armdir%\tcpp -I"%sdkdir%" -c -bigend -O2 -apcs /interwork %options% reg.cpp
%armdir%\tcc -I"%sdkdir%" -c -bigend -O2 -apcs /interwork %options% %opt_l7e% %src_input%
%armdir%\armlink -reloc -first Lib.o(Lib) -o %output% %tmp_o% %ext_o% %lib_o%
del %tmp_o%
if exist %output% (
	echo ACK: File `%output%` created
) else (
	echo ERR: File `%output%` not created
)
7z a -tzip -r -mx9 %p_name%_for_l7eFS.zip %files_to_pack% > _7z.log
echo ---------------------------------------



del *.elf
del _7z.log
if not exist release md release
del release\*.zip
del release\*.elf

move *.zip release\